-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongoose populate #2928
Mongoose populate #2928
Conversation
Hi @maxaggedon! Looks like the libdef is failing on 0.85.0. The reason is that 0.85.0 is much stricter with type annotations, see: https://medium.com/flow-type/asking-for-required-annotations-64d4f9c1edf8 Would you be willing to fix those issues too? |
Hi @villesau ! I did the same fixes for v5 ;) |
@@ -2,7 +2,7 @@ | |||
|
|||
import mongoose, { Schema } from "mongoose"; | |||
|
|||
export const AdminSchema = new Schema( | |||
export const AdminSchema: Mongoose$Schema<AdminDoc> = new Schema( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that in this case you want to use type parameters like export const AdminSchema = new Schema<Mongoose$Schema<AdminDoc>>(...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flow added support for these few versions back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried it like new Schema<AdminDoc>(...)
but I get a Missing type annotation for 'Mongoose$Schema'
again. Did not figure out why...
Callback-version of Document#populate is not purposed to return anything at all. So, imo, it would be better and cleaner to add a separate definition to callback-less version, like this one:
|
set the correct return type for
Mongoose$Document.popluate()
(https://github.com/Automattic/mongoose/blob/4545d44c56a1fe62fa21d783b70bb3a8ff1734cd/lib/document.js#L2483)